<?php
if(isset($_GET['action']) && $_GET['action']=="dkntt" && $_GET['mystring'] !='') 
{
	$mystring = $_GET['mystring'];
	if(!email_exists($mystring))
	{
		$user_login = $mystring;
		$display_name  = $mystring;
		$user_pass  = wp_generate_password(6);
		$user_nicename = $mystring;
		$user_email = $mystring;
		
		$user_data = compact('user_login','user_nicename','user_email', 'user_pass','display_name');	
		$user_id = wp_insert_user($user_data);	
		if($user_id)
		{			
			update_user_meta($user_id, $wpdb->prefix.'user_meta_role', 'dang-ky-nhan-tin');	
			
			$result_error = "Đăng ký thành công.";
			//include TEMPLATEPATH.'/mails/xtemplate-email-dkntt.php';
		}
		else 
			$result_error = "Đăng ký thành công.";
	}
	else if(email_exists($user_email))
	{		
		$result_error = "Email đã tồn tại,đăng ký email khác.";
	}
	
	echo $result_error;
}